import { defineStore } from "pinia";
import axios from "axios";
export const useUsersStore = defineStore("shooing", {
  state() {
    return {
      addVisible: false,
      userData: [],
      total: 0, // 总条数
      currentPage: 1, // 当前页
      pageSize: 3, // 分页大小
      searchContent: "", // 搜索的内容

      editVisible: false,
      userID: 0,
      edituserForm: {},
    };
  },
  actions: {
    userloadData() {
      let params = {
        pageNumber: this.currentPage,
        pageSize: this.pageSize,
        search: this.searchContent,
      };
      axios.get("/users", { params: params }).then((res) => {
        console.log(res);
        this.total = res.data.totalCount;
        this.currentPage = res.data.currentPage;
        this.userData = res.data.list;
      });
    },
    //id查询数据
    userid() {
      axios
        .get("/users/get", { params: { userId: this.userID } })
        .then((res) => {
          this.edituserForm = res.data;
        });
    },
  },
});
